package com.roy.comet.rest;

import com.roy.comet.CometJdbcTemplate;
import com.roy.comet.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ParameterMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by mc on 18/4/10.
 */
@RestController
@RequestMapping(value = "/JDBC")
public class JDBCRest {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private CometJdbcTemplate cometJdbcTemplate;

    /**
     * 插入
     * @return
     */
    @PostMapping(value = "/insert")
    public void inset(){
            User user = new User();
            user.setCreated(new Date());
            user.setDeleted(0);
            user.setName("***");
            user.setPassword("123");
            Integer res = cometJdbcTemplate.update(1,"insert into user(name, password,created,deleted) values(?, ?,?,?)",
                    user.getName(),user.getPassword(),user.getCreated(),user.getDeleted());

            // cometJdbcTemplate.update("UPDATE USER SET name = 'wg123' WHERE  id = ?",1);

    }


}
